package com.personal.gateway.flinkAllCommand.flinkFileSystem;

import com.personal.gateway.custom.customEnum.flinkCommandEnum.FlinkFileSystemEnum;
import com.personal.gateway.flinkAllCommand.configurationOption.ConfigurationOption;
import com.personal.gateway.flinkAllCommand.configurationOption.configurationType.AbstractConfigurationTypeClass;

/**
 * @author BigHead
 * @date 2022/1/19 17:16
 * @description FlinkFileSystemTypeClass
 */
public abstract class FlinkFileSystemTypeClass extends AbstractConfigurationTypeClass {

    public static final Class<AbstractConfigurationTypeClass> FLINK_FILE_SYSTEM_TYPE_CLASS = (Class<AbstractConfigurationTypeClass>) (Class<?>) FlinkFileSystemTypeClass.class;

    protected FlinkFileSystemEnum[] flinkFileSystemEnums;

    public FlinkFileSystemTypeClass() {
        this.flinkFileSystemEnums = setFlinkFileSystemEnums();
    }

    /**
     * 自定义 返回的FlinkTargetEnum 类型
     *
     * @return 数组
     */
    protected abstract FlinkFileSystemEnum[] setFlinkFileSystemEnums();

    @Override
    public boolean checkAntecedent(ConfigurationOption<?, ?> configurationOption) {
        FlinkFileSystemEnum flinkFileSystemEnum = (FlinkFileSystemEnum) configurationOption.getConfigurationType().getValue();
        for (FlinkFileSystemEnum targetFlinkFileSystemEnum : flinkFileSystemEnums) {
            if (flinkFileSystemEnum.equals(targetFlinkFileSystemEnum)) {
                return true;
            }
        }
        return false;
    }
}
